package com.easyCode.feature.mybaits;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class PageResult {
    private Long pageNum;
    private Long pageSize;
    private Long totalPageNum;
    private Long totalRecordNum;
    private List<Object> data;

    protected static void exposePageInfo(IPage page) {
        PageResult pageResult = new PageResult();
        pageResult.setPageNum(page.getCurrent());
        pageResult.setPageSize(page.getSize());
        pageResult.setTotalPageNum(page.getPages());
        pageResult.setTotalRecordNum(page.getTotal());
        PageContext.setPageInfo(pageResult);
    }
}